package com.spinach.game.enums;

import lombok.Getter;

/**
 * Poker level
 *
 * @author nico
 */
@Getter
public enum PokerLevel {

    LEVEL_3(3, "3"),

    LEVEL_4(4, "4"),

    LEVEL_5(5, "5"),

    LEVEL_6(6, "6"),

    LEVEL_7(7, "7"),

    LEVEL_8(8, "8"),

    LEVEL_9(9, "9"),

    LEVEL_10(10, "10"),

    LEVEL_J(11, "J"),

    LEVEL_Q(12, "Q"),

    LEVEL_K(13, "K"),

    LEVEL_A(14, "A"),

    LEVEL_2(16, "2"),

    LEVEL_SMALL_KING(17, "S"),

    LEVEL_BIG_KING(18, "X"),
    ;

    private int level;

    private String name;

    PokerLevel(int level, String name) {
        this.level = level;
        this.name = name;
    }

    public static final PokerLevel parseByName(String name) {
        if (name == null) {
            return null;
        }
        for (PokerLevel level : PokerLevel.values()) {
            if (level.name.equals(name.toUpperCase())) {
                return level;
            }
        }
        return null;
    }

    public static final PokerLevel parseByLevel(int l) {
        for (PokerLevel level : PokerLevel.values()) {
            if (level.level == l) {
                return level;
            }
        }
        return null;
    }
}
